'use strict';

const path = require('path');
const xtpl = require('xtpl');

module.exports.sendMsg = function(msg,res){
	xtpl.renderFile(
		path.join(__dirname,'../views/admin/error.html'),
		{
			msg: msg,
		},
		function(err,content){
			res.setHeader('Content-Type','text/html;charset=utf-8');
			res.send(content);
		}
	);
}

//生成随机数
module.exports.randomString = function (len = 4) {
    len = len || 32;
    var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz0123456789';    /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
    var maxPos = $chars.length;
    var code = '';
    for (var i = 0; i < len; i++) {
        code += $chars.charAt(Math.floor(Math.random() * maxPos));
    }
    return code;
};
